import java.util.Scanner;

public class While02 {

    public static void main(String[] args) {
        // 从键盘输入一个数字，计算1-这个数字的和
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数字");
        int number = sc.nextInt(); // 10
        int sum = 0;
        while (number >= 1) { // number = 10   number = 9 ... number = 1  number = 0
            sum += number;
            number --;
        }
        System.out.println("和是" + sum);
//        int i = 1;
//        while (i <= number) {
//            sum += i;
//            i ++;
//        }
//        System.out.println("1-" + number + "的和是" + sum);
    }
}
